/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package boundless.entities;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author hendrikdekock
 */
@Entity
@Table(name = "GAMEHISTORY")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Gamehistory.findAll", query = "SELECT g FROM Gamehistory g"),
    @NamedQuery(name = "Gamehistory.findByTeam1id", query = "SELECT g FROM Gamehistory g WHERE g.gamehistoryPK.team1id = :team1id"),
    @NamedQuery(name = "Gamehistory.findByTeam2id", query = "SELECT g FROM Gamehistory g WHERE g.gamehistoryPK.team2id = :team2id"),
    @NamedQuery(name = "Gamehistory.findByWeek", query = "SELECT g FROM Gamehistory g WHERE g.gamehistoryPK.week = :week"),
    @NamedQuery(name = "Gamehistory.findByScore1", query = "SELECT g FROM Gamehistory g WHERE g.score1 = :score1"),
    @NamedQuery(name = "Gamehistory.findByScore2", query = "SELECT g FROM Gamehistory g WHERE g.score2 = :score2")})
public class Gamehistory implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected GamehistoryPK gamehistoryPK;
    @Column(name = "SCORE1")
    private Integer score1;
    @Column(name = "SCORE2")
    private Integer score2;
    @JoinColumn(name = "LEAGUE", referencedColumnName = "ID")
    @ManyToOne(optional = false)
    private League league;
    @JoinColumn(name = "TEAM1ID", referencedColumnName = "ID", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Fantasyteams fantasyteams;
    @JoinColumn(name = "TEAM2ID", referencedColumnName = "ID", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Fantasyteams fantasyteams1;

    public Gamehistory() {
    }

    public Gamehistory(GamehistoryPK gamehistoryPK) {
        this.gamehistoryPK = gamehistoryPK;
    }

    public Gamehistory(int team1id, int team2id, int week) {
        this.gamehistoryPK = new GamehistoryPK(team1id, team2id, week);
    }

    public Gamehistory(int team1id, int team2id, int week, League l) {
        this.gamehistoryPK = new GamehistoryPK(team1id, team2id, week);
        league = l;
    }

    
    public GamehistoryPK getGamehistoryPK() {
        return gamehistoryPK;
    }
    
    
    public void setGamehistoryPK(GamehistoryPK gamehistoryPK) {
        this.gamehistoryPK = gamehistoryPK;
    }

    public Integer getScore1() {
        return score1;
    }

    public void setScore1(Integer score1) {
        this.score1 = score1;
    }

    public Integer getScore2() {
        return score2;
    }

    public void setScore2(Integer score2) {
        this.score2 = score2;
    }

    public League getLeague() {
        return league;
    }

    public void setLeague(League league) {
        this.league = league;
    }

    public Fantasyteams getFantasyteams() {
        return fantasyteams;
    }

    public void setFantasyteams(Fantasyteams fantasyteams) {
        this.fantasyteams = fantasyteams;
    }

    public Fantasyteams getFantasyteams1() {
        return fantasyteams1;
    }

    public void setFantasyteams1(Fantasyteams fantasyteams1) {
        this.fantasyteams1 = fantasyteams1;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (gamehistoryPK != null ? gamehistoryPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Gamehistory)) {
            return false;
        }
        Gamehistory other = (Gamehistory) object;
        if ((this.gamehistoryPK == null && other.gamehistoryPK != null) || (this.gamehistoryPK != null && !this.gamehistoryPK.equals(other.gamehistoryPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "boundless.entities.Gamehistory[ gamehistoryPK=" + gamehistoryPK + " ]";
    }
    
}
